home *** CD-ROM | disk | FTP | other *** search
/ Amiga Packmags / Source, The - Issue 5 (1993)(Epsilon)[WB].zip / Source, The - Issue 5 (1993)(Epsilon)[WB].adf / Source / Music / GMod.lha / dw_gmod.asm < prev    next >
Assembly Source File  |  1992-05-25  |  4KB  |  99 lines

  1. * DW_GMOD.asm
  2. *
  3. * This is a very simple example of a GMOD interface.  It can be used
  4. * to turn Dave Whittaker modules into GMOD modules by tacking a
  5. * short GMOD header onto the beginning of the file.  (I chose this
  6. * particular format since the player code is already embedded in the
  7. * module, so it doesn't need to be included here.)  To make a
  8. * working example program, you'll have to link it with DW_Convert.c
  9. * (assuming you have a C compiler).
  10. *
  11. * To use this code (or a variation you create to play your own type
  12. * of module), the main program that actually writes modules to disk
  13. * simply needs to copy this bit of code out just before the main
  14. * module.  An example of how to do this is in a high-level language
  15. * is shown in DW_Convert.c; in assembly language this operation is
  16. * trivial.
  17. *
  18. * If you want to assemble this code directly into a module (i.e.
  19. * using 'INCBIN' at the end to include the module), you can do this,
  20. * but you'll either have to tell your assembler to output in 'raw'
  21. * format (without standard AmigaDOS object file headers and such) or
  22. * manually strip off the baggage after assembling.
  23. *
  24. * Always remember that all GMOD code such as this must be completely
  25. * PC-relative (unless you do your own relocation or use the
  26. * gmod_LoadAddress to specify an absolute start address, which
  27. * hopefully you won't do).
  28.  
  29.  
  30.     include "GMOD.i"
  31.  
  32.  
  33.     section    "__MERGED",data
  34.  
  35. *** Entrypoints in Dave Whittaker modules
  36. *** (offsets from the beginning of the original DW module)
  37.  
  38. * Note that DW modules nicely save all registers, so we can jump to these
  39. * entrypoints directly.  Other types of player code may need a little
  40. * code to save and restore registers D2-D7/A2-A6.
  41.  
  42. dwstartentry    equ    $00
  43. dwvbentry    equ    $0e
  44. dwstopentry    equ    $1c
  45.  
  46.  
  47. * We use the _HeaderBegin and _HeaderEnd labels in the DW_Convert.c program
  48. * to find out where and how big the header is.
  49.     xdef    _HeaderBegin,_HeaderEnd
  50. _HeaderBegin:
  51.  
  52.  
  53. * This structure must be at the very beginning of the file.
  54. first:
  55.     dc.l    'GMOD'                  ; ID
  56.     dc.l    '_DW_'                  ; Maker (doesn't really matter in this case)
  57.     dc.l    0                       ; LoadAddress (zero means relocatable)
  58.     dc.l    gmod_Hook               ; MaxVecOfs (one entry past the last one)
  59.     gmodnop                         ; InitMusic
  60.     gmodbra    dwmodule+dwstartentry   ; StartMusic
  61.     gmodbra    dwmodule+dwstopentry    ; StopMusic
  62.     gmodnop                         ; EndMusic
  63.     gmodnop                         ; Reserved
  64.     gmodnop                         ; ContinueMusic
  65.     gmodbra dwmodule+dwvbentry      ; VBlank50
  66.     gmodnop                         ; VBlank60
  67.     gmodnop                         ; Channel0
  68.     gmodnop                         ; Channel1
  69.     gmodnop                         ; Channel2
  70.     gmodnop                         ; Channel3
  71.     gmodnop                         ; GetNumSongs
  72.     gmodnop                         ; GetSongName
  73.     gmodbra getauthor               ; GetSongAuthor
  74.     gmodnop                            ; GetFrequency
  75.     gmodnop                         ; TimerTick
  76.         gmodnop                         ; GetMakerName
  77.                                     ; Hook (first unused entry)
  78.  
  79.  
  80. * Example of an optional entrypoint for author identification
  81. getauthor:
  82.     lea    authorname(pc),a0
  83.     move.l    a0,d0    ; All returns are in D0
  84.     rts
  85.  
  86. authorname    dc.b    "Dave Whittaker",0
  87.  
  88.     cnop    0,4    ; Pad out to the next longword boundary just to be safe
  89.  
  90. * DW_Convert.c uses this label to find out how big the header is...
  91. _HeaderEnd:
  92.  
  93.  
  94. * The actual module begins right at this label...
  95. dwmodule:
  96.  
  97.  
  98.     end
  99.